<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/4
 * Time: 17:38
 */

namespace app\service;


use app\models\CouponModal;

class CouponService
{
    /**
     * 校验优惠券id是否有效
     */
    public function checkValid($id)
    {
        $coupon = new CouponModal();
        $re = $coupon->one('*', ['number_no' => $id]);
        if ($re) {
            if ($re['expire_time'] > time() && $re['is_active'] == 1) {
                return true;
            }
        }
        return false;
    }

    /**获取优惠券优惠数值
     * @param $num
     */
    public function getFree($num)
    {
        $coupon = new CouponModal();
        return $coupon->one('*', ['number_no' => $num]);
    }
}